<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件</title>
</head>

<body>

    <button id="aaa">点击</button>

</body>

<script>
    var a = document.getElementsByTagName('button');

    a[0].onclick = function() {
        alert("你好")
    }
</script>

</html>